package com.cxf.windex.base.util;

/**
 * @program: cxf-blog
 * @description: 字母转换
 * @author: chenxf
 * @create: 2018-08-09 10:27
 **/
public class LetterConvert {
  // 将字母转换成数字_1
  public static String t1(String input) {
    String reg = "[a-zA-Z]";
    StringBuffer strBuf = new StringBuffer();
    input = input.toLowerCase();
    if (null != input && !"".equals(input)) {
      for (char c : input.toCharArray()) {
        if (String.valueOf(c).matches(reg)) {
          strBuf.append(c - 96);
        } else {
          strBuf.append(c);
        }
      }
      return strBuf.toString();
    } else {
      return input;
    }
  }

  // 将字母转换成数字
  public static void letterToNum(String input) {
    for (byte b : input.getBytes()) {
      System.out.print(b - 96);
    }
  }

  // 将数字转换成字母
  public static void numToLetter(String input) {
    for (byte b : input.getBytes()) {
      System.out.print((char) (b + 48));
    }
  }

  public static String numToLetterStr(String input) {
    for (byte b : input.getBytes()) {
      char c=(char) (b + 48);
      return (c+"").toUpperCase();
    }
    return "";
  }

  public static void main(String[] args) {
    String i1 = "abcdef";
    String i2 = "1";
    letterToNum(i1);
    System.out.println( numToLetterStr(i2));


  }

}
